package com.ny.demo03;

import java.sql.SQLException;
import java.util.Scanner;

public class View {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入姓名：");
        String name = scanner.nextLine();

        System.out.print("请输入年龄：");
        int age = scanner.nextInt();
        scanner.nextLine(); // 清除换行符

        System.out.print("请输入部门：");
        String department = scanner.nextLine();

        Employee employee = new Employee(name, age, department);
        EmployeeDao dao = new EmployeeDao();

        // 接收返回的 Employee 对象
        Employee result = dao.insertEmployee(employee);

        // 判断是否保存成功（根据你的 EmployeeDao 的逻辑，可以简单判断 result 是否非空）
        if (result != null) {
            System.out.println("员工信息保存成功！");
        } else {
            System.out.println("员工信息保存失败！");
        }

        scanner.close();
    }
}

